package ar.edu.itba.it.cg.grupo01.impl.color;

import java.awt.Color;
import java.util.List;
import java.util.Random;

import com.google.common.collect.ImmutableList;
import static com.google.common.base.Preconditions.*;

import ar.edu.itba.it.cg.grupo01.api.color.ColorMode;

public class ColorModeFactory {

	private static final List<Color> ORDERED_COLORS = ImmutableList.of(
			new Color(127, 0, 255), Color.BLUE, Color.CYAN, Color.DARK_GRAY,
			Color.GREEN, Color.LIGHT_GRAY, Color.MAGENTA, Color.ORANGE,
			Color.PINK, Color.RED, Color.WHITE, Color.YELLOW);
	private final Random random;

	public ColorModeFactory(final Random random) {
		this.random = random;
	}

	public ColorMode forName(final String name) {

		checkNotNull(name, "Color mode name should not be null");

		if (name.equals("random")) {
			return new RandomColorMode(random);
		} else if (name.equals("ordered")) {
			return new OrderedColorMode(ORDERED_COLORS);
		}

		throw new IllegalArgumentException("No color mode for name: " + name);
	}

}
